﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:utils="clr-namespace:Passwords.Utils"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="appProgressBarStyle" TargetType="{x:Type ProgressBar}">
        <Setter Property="Foreground" Value="{DynamicResource AppAccentBrush}"/>
        <Setter Property="Background" Value="#30808080"/>
        <Setter Property="BorderBrush" Value="{DynamicResource AppForeground}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ProgressBar}">
                    <Grid x:Name="TemplateRoot" SnapsToDevicePixels="true">
                        <Rectangle Fill="{TemplateBinding Background}" />
                        <Rectangle x:Name="PART_Track" Margin="1"/>
                        <Decorator x:Name="PART_Indicator" HorizontalAlignment="Left" Margin="1">
                            <Grid x:Name="Foreground">
                                <Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
                                <Grid x:Name="Overlay">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition MaxWidth="15"/>
                                        <ColumnDefinition Width="0.1*"/>
                                        <ColumnDefinition MaxWidth="15"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                </Grid>
                            </Grid>
                        </Decorator>
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="LayoutTransform" TargetName="TemplateRoot">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="pwsAppProgressBarStyle" TargetType="ProgressBar" BasedOn="{StaticResource appProgressBarStyle}">
        <Style.Resources>
            <utils:PasswordStrengthConverter x:Key="pwsConverter"/>
        </Style.Resources>
        <Setter Property="Foreground" Value="Lime"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ProgressBar}">
                    <Grid x:Name="TemplateRoot" SnapsToDevicePixels="true">
                        <Rectangle Fill="{TemplateBinding Background}" />
                        <Rectangle x:Name="PART_Track" Margin="1"/>
                        <Decorator x:Name="PART_Indicator" HorizontalAlignment="Left" Margin="1">
                            <Grid x:Name="Foreground">
                                <Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
                                <Grid x:Name="Overlay">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition MaxWidth="15"/>
                                        <ColumnDefinition Width="0.1*"/>
                                        <ColumnDefinition MaxWidth="15"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                </Grid>
                            </Grid>
                        </Decorator>
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="LayoutTransform" TargetName="TemplateRoot">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>

                        <DataTrigger Binding="{Binding Value, Converter={StaticResource pwsConverter}, RelativeSource={RelativeSource Self} }" Value="0">
                            <Setter Property="Foreground" Value="Red"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Value, Converter={StaticResource pwsConverter}, RelativeSource={RelativeSource Self} }" Value="1">
                            <Setter Property="Foreground" Value="Orange"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Value, Converter={StaticResource pwsConverter}, RelativeSource={RelativeSource Self} }" Value="2">
                            <Setter Property="Foreground" Value="Green"/>
                        </DataTrigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
        </Style.Triggers>
    </Style>

</ResourceDictionary>